 package cn.edu.scau.cmi.linkaibo.client;


import cn.edu.scau.cmi.linkaibo.spring.domain.Student;
import cn.edu.scau.cmi.linkaibo.spring.domain.Teacher;
import cn.edu.scau.cmi.linkaibo.spring.util.ApplicationContextUtil;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.ApplicationContext;

public class SpringSingletonApplicationContextClient {

 private static Teacher liangzaoqing;
 private static Student zhangsan;

 public SpringSingletonApplicationContextClient() {
 }

 public static void main(String[] args) {
  ApplicationContext ac = getApplicationContext();
  Student zhangsan=(Student) ac.getBean("zhangsan");
  zhangsan.setName("张三");
  Teacher liangzaoqing = (Teacher)ac.getBean("liangzaoqing");
  liangzaoqing.setName("梁早清");
  zhangsan.setTutor(liangzaoqing);
  System.out.println(zhangsan.getName()+"的指导导师是："+zhangsan.getTutor().getName());
 }


 private static ApplicationContext getApplicationContext() {
  ApplicationContext applicationContext=ApplicationContextUtil.getApplicationContext();
  return applicationContext;
 }

} 